// 首页js
var $scope = null;
$(function() {
	var appElement = document.querySelector('[ng-controller=main]');
	$scope = angular.element(appElement).scope();
	  initialPage($scope);
	  //首页动态轮播
	  $scope.methods.getCarouselList();
	  //消息动态列表
	$scope.methods.dynamicList();
	// 首页大数据
	$scope.methods.bigData();
});
// 初始化值
function initialPage($scope) {
	
	
}
var mainApp = angular.module("mainApp", []);
mainApp.controller('main', function($scope) {
	$scope.search={};
	$scope.methods = {
		//首页动态轮播
		getCarouselList: function() {
			$.ajax({
			    url:$.shysUrlPrefix+'/website/getCarouselList',
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				  beforeSend: function () {
				        $(".loading").show();
				    },
			    success:function (data) {
					if (data.data != null  ) {
					 $scope.getCarouselList = data.data;
					 console.log( $scope.getCarouselList)
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				 complete: function () {
				        $(".loading").hide();
				    },
			
			})
		},
		//动态列表
		dynamicList : function() {
			var params = '';
			params += '&pageNum=1'
			params += '&pageSize=8'
			params += '&status=1'
			$.ajax({
			    url:$.shysUrlPrefix+'/website/dynamicList?'+params,
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				  beforeSend: function () {
				        $(".loading").show();
				    },
			    success:function (data) {
					if (data.rows != null && data.rows.length > 0 ) {
					  $scope.dynamicList = data.rows;
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				 complete: function () {
				        $(".loading").hide();
				    },
			
			})
		},
		//首页大数据
		bigData: function() {
			$.ajax({
			    url:$.shysUrlPrefix+'/website/bridge/bigData',
			    type:'get',
			    dataType:'JSON',
				async:true,  //同步方式发起请求
				  beforeSend: function () {
				        $(".loading").show();
				    },
			    success:function (data) {
					if (data.data != null  ) {
					$scope.bigData = data.data.data.bridgeGroup;
					$scope.bridgeCount = data.data.data.bridgeCount;
					$scope.oldBridgeCount = data.data.data.oldBridgeCount;
					$scope.xdBridgeCount = data.data.data.xdBridgeCount;
					 console.log(data.data)
					   $scope.$apply();
					} else {
					   
					}
					
			    },
				 complete: function () {
				        $(".loading").hide();
				    },
			
			})
		},
		// 跳转详情页
		labelDetailClick: function (label) {
		 window.location.href="dongtai-detail.html?dynamicId="+label.dynamicId
		},
		// 更多跳转资源
		moreClick: function () {
		 window.location.href="resource.html"
		},
		//图集跳转到相应界面
		moreExpert: function (label) {
		 window.location.href="resource.html?dynamicTypeId="+label
		},
		
	};
});











